package com.ds.common.web.response;

import com.ds.common.response.ResponseCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    /**
     * 是否成功
     */
    private Boolean success;

    /**
     * 响应code
     */
    private String code;

    /**
     * 响应信息
     */
    private String msg;

    /**
     * 响应数据
     */
    private T data;


    public static <T> Result<T> success(T data) {
        return new Result<>(true, ResponseCode.SUCCESS.name(), ResponseCode.SUCCESS.name(), data);
    }

    public static <T> Result<T> error(String errorCode,String errorMsg) {
        return new Result<>(false, errorCode, errorMsg, null);
    }
}
